package com.imooc.config;

import com.imooc.service.OrderService;
import com.imooc.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class OrderJob {
    @Autowired
    OrderService orderService;
    //每隔3秒执行一次
//    @Scheduled(cron = "0/3 * * * * ?")
    //每隔1小时，整点执行一次
    @Scheduled(cron = "0 0 0/1 * * ?")
    public void autoCloseOrder(){
        orderService.closeOrder();
        System.out.println("当前时间是："+ DateUtil.getCurrentDateString(DateUtil.DATETIME_PATTERN));
    }
}
